package com.example.learnspring.exception;

import com.example.learnspring.entity.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public Result globalExceptionHandler(Exception ex){
        return Result.error(ex.getMessage());
    }
}
